package service;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;

import communication.ParameterizedMessage;
import communication.ParameterizedMessageImpl;

public class MockService extends AbstractService {

	@Override
	public void init() throws Exception {
		Logger logger = Logger.getLogger(MockService.class);
		logger.info("MockService init.");
	}

	@Override
	public void run() {
		Logger logger = Logger.getLogger(MockService.class);
		logger.info("MockService started to run.");
		
		try {
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@Override
	public void close(ParameterizedMessage message) {
		Logger logger = Logger.getLogger(MockService.class);
		logger.info("MockService closed.");
	}

	public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, InterruptedException {
		BasicConfigurator.configure();
		
		Logger.getLogger("org.jgroups").setLevel(Level.ERROR);
		
		ServiceWrapper wrapper = new ServiceWrapper();
		
		wrapper.mainLoop("cn.edu.zju.retina.service.MockService");
	}
}
